/*
 *             Copyright (C) 2024 Steve Jrong
 *
 * 	   GitHub Homepage: https://www.github.com/SteveJrong
 *      Gitee Homepage: https://gitee.com/stevejrong1024
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.stevejrong.waiter.user.domainservice.impl;

import org.springframework.stereotype.Service;

import com.stevejrong.waiter.user.domainservice.IGuestDomainService;
import com.stevejrong.waiter.user.gateway.IGuestGateway;
import com.stevejrong.waiter.user.model.aggregates.Guest;

import lombok.AllArgsConstructor;
import reactor.core.publisher.Mono;

/**
 * @author Steve Jrong
 * @since 1.0
 */
@Service("guestDomainService")
@AllArgsConstructor
public class GuestDomainServiceImpl implements IGuestDomainService {
    private IGuestGateway guestGateway;

    // @Transactional
    @Override
    public Mono<Void> create(Guest guest) {
    	return Mono.defer(() -> guest.create())
    	 .flatMap(createdGuest -> guestGateway.save(createdGuest));
    }

    // @Transactional
    @Override
    public Mono<Void> bindTel(String wxOpenId, String tel) {
//        // 获取原顾客信息
//        Guest guest = guestGateway.getByWxOpenId(wxOpenId);
//        // 更新手机号
//        guest.updateTel(tel);
//        // 持久化
//        guestGateway.update(guest);
    	
    	return null;
    }

    @Override
    public Mono<Boolean> checkTelBound(String wxOpenId) {
//        Guest guest = guestGateway.getByWxOpenId(wxOpenId);
//        return guest.checkTelBound();
    	
    	return null;
    }
}